<template>
  <uv-swiper :list="fileList" height="704rpx"></uv-swiper>
</template>
<script setup>
import api from '@/api/upload/upload';
import {ref, getCurrentInstance, watchEffect} from 'vue';

const {proxy} = getCurrentInstance();
const props = defineProps({
  tableId: {      // 表id
    type: String,
    default: ''
  },
  tableName: {    // 表名称
    type: String,
    default: ''
  },
  type: {         // 表文件类型
    type: String,
    default: ''
  },
  fileType: {     // 文件类型
    type: String,
    default: 'img'
  },
});
let fileList = ref([]); // 文件列表

// 初始化数据
let init = async (e) => {
  if(props.tableId) {
    let query = {};
    query.tableId = props.tableId;
    query.tableName = props.tableName;
    query.type = [props.type];
    let res = await proxy.http.asyncPost(api.findFileList, query);
    if (res.code === 0) {
      fileList.value = res.data.map((p) => p.url);
    } else {
      uni.showToast({title: res.msg, icon: 'none'});
    }
  }
}

watchEffect(()=>{
  init();
})

</script>
<style scoped lang="scss">
.image-box {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: flex-start;
  image {
    flex-shrink: 0;
    width: 144rpx;
    height: 144rpx;
    border-radius: 8rpx;
    margin-right: 10rpx;
  }
}
</style>